package com.chaoyong.higo.fragment;

import com.chaoyong.higo.R;
import com.chaoyong.higo.adapter.ViewPageFragmentAdapter;
import com.chaoyong.higo.base.BaseViewpagerFragmentNormal;
import com.chaoyong.higo.interf.OnTabReselectListener;

import android.support.v4.app.Fragment;

/**
 * 装载三个fragment用，分别是云筹记录--全部、进行中、已揭晓
 * @author Administrator
 *
 */
public class FragRecordPager extends BaseViewpagerFragmentNormal implements OnTabReselectListener{

	@Override
	protected void onSetupTabAdapter(ViewPageFragmentAdapter adapter) {
		 String[] title = getResources().getStringArray(
	                R.array.records);
		 adapter.addTab(title[0], "all", FragRecordAll.class);
		 adapter.addTab(title[1], "running", FragRecordRunning.class);
		 adapter.addTab(title[2], "known", FragRecordKnown.class);
	}
	
	@Override
	protected void setScreenPageLimit() {
		mViewPager.setOffscreenPageLimit(3);
	}
	
	@Override
	public void onTabReselect() {
		try {
			int currentIndex = mViewPager.getCurrentItem();
			Fragment currentFragment = getChildFragmentManager().getFragments().get(currentIndex);
			if (currentFragment != null && currentFragment instanceof OnTabReselectListener ) {
				OnTabReselectListener listener = (OnTabReselectListener) currentFragment;
				listener.onTabReselect();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
